package com.sujing.autoUpdate.sqlOption;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class NewVersion {


	public float NewVersion(String FileName) {
		String Driver="com.mysql.jdbc.Driver";
		String url="jdbc:mysql://127.0.0.1:3306/uploadfile";
		String user="root";
		String password="123456";
		try {
			Class.forName(Driver);
			try {
				Connection conn=DriverManager.getConnection(url, user, password);
				String sql="select max(FileVersion) from file where FileName=?";
				if(!conn.isClosed())
					System.out.println("Success database!!");
				PreparedStatement pstmt=conn.prepareStatement(sql);
				pstmt.setString(1, FileName);
				ResultSet rs=pstmt.executeQuery();
				while(rs.next()){
					return rs.getFloat("max(FileVersion)"); 
				}
				
				pstmt.close();
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return (float) 1.00;
		
	}

}
